# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=opcr-policy
pkgver=0.2.8
pkgrel=0
pkgdesc="CLI for building, versioning and publishing authorization policies"
url="https://www.openpolicycontainers.com/"
arch="all"
license="Apache-2.0"
makedepends="go"
source="$pkgname-$pkgver.tar.gz::https://github.com/opcr-io/policy/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/policy-$pkgver"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	local _goldflags="
	-X github.com/opcr-io/policy/pkg/version.ver=$pkgver
	-X github.com/opcr-io/policy/pkg/version.commit=AlpineLinux
	-X github.com/opcr-io/policy/pkg/version.date=$(date -u "+%Y-%m-%dT%H:%M:%SZ" ${SOURCE_DATE_EPOCH:+-d @$SOURCE_DATE_EPOCH})
	"

	go build -v -ldflags "$_goldflags" ./cmd/policy/
}

check() {
	go test ./...
}

package() {
	install -Dm755 policy -t "$pkgdir"/usr/bin/
}

sha512sums="
0f5bea335fdff92362778f028bfbd89839d316b9e9a95296874f81b5263b5c815e57ca31ae62c6e96b44d8d02f07f759b6be9c2437db41260ecff3f3ed790f3b  opcr-policy-0.2.8.tar.gz
"
